package com.usian.wemedia.controller.v1;

import com.usian.api.wemedia.WmMaterialControllerApi;
import com.usian.common.constants.wemedia.WemediaContants;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController implements WmMaterialControllerApi {
    @Autowired
    private WmMaterialService materialService;

    @PostMapping("/upload_picture")
    @Override
    public ResponseResult uploadPicture(MultipartFile file) {
        return materialService.uploadPicture(file);
    }

    @Override
    @GetMapping("/cancel_collect/{id}")
    public ResponseResult cancleCollectionMaterial(Integer id) {
        return materialService.updateStatus(id, WemediaContants.CANCEL_COLLECT_MATERIAL);
    }

    @GetMapping("/collect/{id}")
    @Override
    public ResponseResult collectionMaterial(@PathVariable("id") Integer id) {
        return materialService.updateStatus(id, WemediaContants.COLLECT_MATERIAL );
    }

}